package com.gp.sys.domain;

import java.util.ArrayList;
import java.util.List;

import com.gp.base.BaseDomain;

/**
 * Resource entity. @author MyEclipse Persistence Tools
 */

public class SysResource extends BaseDomain implements java.io.Serializable {

	// Fields

	private String id;
	private String type;
	private String value;
	private String remark;
	private String deleteFlag;

	private List<SysRole> sysRoles = new ArrayList<SysRole>();
	// Constructors

	/** default constructor */
	public SysResource() {
	}

	/** minimal constructor */
	public SysResource(String id) {
		this.id = id;
	}

	/** full constructor */
	public SysResource(String id, String type, String value, String remark,
			String deleteFlag) {
		this.id = id;
		this.type = type;
		this.value = value;
		this.remark = remark;
		this.deleteFlag = deleteFlag;
	}

	// Property accessors

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getType() {
		return this.type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getValue() {
		return this.value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getDeleteFlag() {
		return this.deleteFlag;
	}

	public void setDeleteFlag(String deleteFlag) {
		this.deleteFlag = deleteFlag;
	}

	public List<SysRole> getSysRoles() {
		return sysRoles;
	}

	public void setSysRoles(List<SysRole> sysRoles) {
		this.sysRoles = sysRoles;
	}
	
	public String getRoleAuthorities() {
    	StringBuffer sb = new StringBuffer();
    	for(SysRole role : sysRoles) {
    		sb.append(role.getRoleNo());
    		sb.append(",");
    	}
    	
    	if(sb.lastIndexOf(",") > -1){
    		return sb.substring(0, sb.lastIndexOf(","));
    	}
    	else{    	
    		return sb.toString();
    	}
    }
	
	
}